package com.mjfeed.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * @description 角色
 * @author zhaominglei
 * @date 2014年9月20日
 */
@Entity
@Table(name = "feed_role")
public class Role extends BaseEntity implements Serializable {
	private static final long serialVersionUID = 6412966534167646682L;
	/** 名称 */
	private String name;
	/** 描述 */
    private String description;
    /** 是否是超级管理员 */
    private Boolean isSystem;
    /** 管理员 */
    private Set<Admin> admins = new HashSet<Admin>();
    /** 权限 */
    private Set<Permission> permissions = new HashSet<Permission>();
    
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name="is_system", columnDefinition = "BIT", nullable=false)
	public Boolean getIsSystem() {
		return isSystem;
	}

	public void setIsSystem(Boolean isSystem) {
		this.isSystem = isSystem;
	}

	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="feed_admin_role", joinColumns = { @JoinColumn(name = "role_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "admin_id", updatable = false) })
	public Set<Admin> getAdmins() {
		return admins;
	}

	public void setAdmins(Set<Admin> admins) {
		this.admins = admins;
	}

	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="feed_role_permission", joinColumns = { @JoinColumn(name = "role_id", updatable = false) },	inverseJoinColumns = { @JoinColumn(name = "permission_id", updatable = false) })
	public Set<Permission> getPermissions() {
		return permissions;
	}

	public void setPermissions(Set<Permission> permissions) {
		this.permissions = permissions;
	}
}
